import {
  queryGetApprovalSummaryReq,
  queryGetErrDistributionSummaryReq,
  queryGetLocalUserAuthReq,
  queryGetOverviewSummaryReq,
  queryGetReqTrendSummaryReq,
  queryGetTopApiErrReqSummaryReq,
  queryGetTopApiReqSummaryReq,
  queryGetTopUserReqSummaryReq,
} from './api'

export default {
  namespace: 'generalView',
  state: {},

  effects: {
    * queryGetOverviewSummary({ params, cb }, { call, put }) {
      const res = yield call(queryGetOverviewSummaryReq, params)
      if (res && cb) {
        cb(res)
      }
    },
    * queryGetApprovalSummary({ params, cb }, { call, put }) {
      const res = yield call(queryGetApprovalSummaryReq, params)
      if (res && cb) {
        cb(res)
      }
    },
    * queryGetReqTrendSummary({ params, cb }, { call, put }) {
      const res = yield call(queryGetReqTrendSummaryReq, params)
      if (res && cb) {
        cb(res)
      }
    },
    * queryGetTopUserReqSummary({ params, cb }, { call, put }) {
      const res = yield call(queryGetTopUserReqSummaryReq, params)
      if (cb) {
        cb(res)
      }
    },
    * queryGetTopApiReqSummary({ params, cb }, { call, put }) {
      const res = yield call(queryGetTopApiReqSummaryReq, params)
      if (cb) {
        cb(res)
      }
    },
    * queryGetTopApiErrReqSummary({ params, cb }, { call, put }) {
      const res = yield call(queryGetTopApiErrReqSummaryReq, params)
      if (cb) {
        cb(res)
      }
    },
    * queryGetErrDistributionSummary({ params, cb }, { call, put }) {
      const res = yield call(queryGetErrDistributionSummaryReq, params)
      if (cb) {
        cb(res)
      }
    },
    * queryGetLocalUserAuth({ params, cb }, { call, put }) {
      const res = yield call(queryGetLocalUserAuthReq, params)
      if (cb) {
        cb(res)
      }
    },
  },
  reducers: {},
}
